package reflect;

class Person{
	
	String name;
	int age; 
	
	public Person(){}
	
	public Person(String name, int age) {
		super();
		this.name = name;
		this.age = age;
	}
	 
	public int sum(int a,int b){
		
		return a+b;
	}

	public void hello(){
		System.out.println("hello world reflect");
	}
	 
	public static void hi(String name){
		System.out.println("你好"+name);
	}
	
}

public class Test1 {

	public static void main(String[] args) {
		// 1 由对象得到
		Person temo= new Person();
		Class c= temo.getClass();
		
		System.out.println("c="+ c.getName() );
		System.out.println("父亲="+c.getSuperclass().getName() );
		
		//2 由包路径 类名找
		try {
			Class c1= Class.forName("reflect.Person");
			System.out.println("c1="+ c1.getName() );
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		// 3 由类名
	    Class c2=Integer.class;
	    System.out.println("c2="+ c2.getName() );
	    
	    //ArrayList父亲？？
	    
	   Class c3= int.class;
	   System.out.println("c3="+ c3.getName() );

	}

}
